package ${packageName};

import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import cn.ysnk.clz.config.annotation.EntityAnnotation;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
@EntityAnnotation(tableName="${model.tableName}")
/**
*自动生成${name}实体类
*/
public class ${model.upEntityFileName} extends Model<${model.upEntityFileName}>{
    public static final ${model.upEntityFileName} dao = new ${model.upEntityFileName}();
	public static final String tableName = "${model.tableName}";
	
	<#if model.hasKeywordsSearch> 
	public Page<${model.upEntityFileName}> findAllPage${model.upEntityFileName}sByKeywords(int pageNumber,int pageSize,List<String> keywordsList){
		StringBuffer whee=new StringBuffer();
        List<Object> param=new ArrayList<Object>();
        for(String words:keywordsList){
	        	if(!("".equals(words.trim()))){
	        		if(whee.length()>0)
	        			whee.append(" or ${model.searchColumn.columnName} like ?");
	        		else
	        			whee.append(" ${model.searchColumn.columnName} like ?");
			        param.add("%"+words+"%");
	        	}
        }
        if(whee.length()>0){
        		whee.insert(0, " where (").append(") ");
        }
		return dao.paginate(pageNumber, pageSize, "select * ", " from ${model.tableName} "+ whee.toString()+" order by createTime desc ",param.toArray());
	
	}  
    <#else>
    public Page<${model.upEntityFileName}> findAllPage${model.entityFileName}s(int pageNumber,int pageSize){
		return dao.paginate(pageNumber, pageSize, "select * ", " from ${model.tableName}  order by createTime desc ");
	}  
    
	</#if>

<#list model.columns as column>
    ${column.getStr}
    ${column.setStr}
</#list>
	${model.saveMethod}
    
}